'use strict';
/**
 * @bussiness {登录}
 * @author {JC}
 * @date {2022-09-26}
 * **/
const Service = require('egg').Service;
const tools = require("../../middleware/utils/tool"); // 创建随机id和获取即时时间工具
class Login extends Service {
    async checklogin(params) {
        const checkoutPhone = await this.app.mysql.get('users', {cellphone: params.cellphone,})
        const checkoutPsd = await this.app.mysql.get('users', {password: params.password})
        const checkStatus = {
            status: null,
            data: checkoutPhone
        }
        if (checkoutPhone && checkoutPsd) {
            checkStatus.status = true
            return checkStatus
        }else if(checkoutPhone==null){
            checkStatus.NotFound = true
            return checkStatus
        } 
        else if (!checkoutPhone) { // 判断手机
            checkStatus.phoneError = true
            return checkStatus
        } else if (!checkoutPsd) { // 判断密码
            checkStatus.psdError = true
            return checkStatus
        } else {
            checkStatus.Error = true
            return checkStatus
        }
    }
}
module.exports = Login;